<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /* 
            第一种：
                字符串转数组，反转数组，数组转字符串。
                
                split("")：根据空字符串拆分数组
                reverse()：数组反转元素位置
                join("")：数组转回字符串,且不带分隔符
        */

        let str = '长叹息以掩涕兮';
        let arr = str.split("");
        arr = arr.reverse();
        str = arr.join("");
        console.log(str);

        // 倒着遍历字符串，并定义新的空字符串
        let result = "此诚危急存亡之秋也";
        let newStr = "";
        for (let i = 0; i < result.length; i++) {
            let temp = result[result.length - 1 - i];
            console.log(temp);
            newStr = newStr + temp;
        }
        console.log(newStr);

    </script>
</body>
</html>